package com.czy.controller;

import com.czy.common.annotation.SystemControllerLog;
import com.czy.common.exception.AuthException;
import com.czy.common.exception.CustomException;
import com.czy.common.model.Result;
import com.czy.entity.StudentEntity;
import com.czy.service.DemoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author czy
 * @date 2021-5-19 11:44
 */
@RestController
@RequestMapping("/demo")
@Api(value = "测试模块",tags = "测试模块")
@Slf4j
public class DemoController {
    @Autowired
    private DemoService demoService;

    @GetMapping("/api")
    @ApiOperation(value = "测试接口")
    @SystemControllerLog(description = "测试api")
    public Result api(String m){
        System.out.println(m);
        return Result.success();
    }

    @PostMapping("/convert")
    @ApiOperation(value = "测试转换")
    @SystemControllerLog(description = "测试转换")
    public Result convert(@RequestBody StudentEntity studentEntity){
        System.out.println(studentEntity);
        return Result.success();
    }

    @GetMapping("/testErrorResponse")
    @ApiOperation(value = "测试错误页返回")
    @SystemControllerLog(description = "测试错误页返回")
    public Result testErrorResponse(){
        throw new AuthException("无权限访问",401);
    }

}
